package com.yeyks.controller.other;

import com.yeyks.common.ajax.AjaxResponseBody;
import com.yeyks.common.param.screen.DataScreenOrderParam;
import com.yeyks.common.result.screen.*;
import com.yeyks.commonReference.service.hotel.HotelInfoService;
import com.yeyks.commonReference.service.order.OrderHeadService;
import com.yeyks.commonReference.service.other.DataCenterService;
import com.yeyks.consumer.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

@Api(tags = "数据大屏")
@RestController
@RequestMapping("/screen")
public class DataScreenController {

    @Autowired
    private OrderHeadService orderHeadService;
    @Autowired
    private UserInfoService userInfoService;
    @Autowired
    private HotelInfoService hotelInfoService;
    @Autowired
    private DataCenterService dataCenterService;

    @ApiIgnore
    @ApiOperation(value = "v4.0.1 --> 同步省名称")
    @PostMapping(value = "/sync/province")
    public AjaxResponseBody syncProvince() {
        orderHeadService.syncProvinceName();
        return AjaxResponseBody.success();
    }

    @ApiOperation(value = "v4.0.1 --> 全国销售额", response = DataScreenOrderResult.class)
    @PostMapping(value = "/stat/order")
    public AjaxResponseBody<DataScreenOrderResult> statOrder(@Validated DataScreenOrderParam param) {
        DataScreenOrderResult result = orderHeadService.statOrder(param);
        return AjaxResponseBody.success(result);
    }

    @ApiOperation(value = "v4.0.1 --> 全国城市业绩", response = DataScreenCityOrderResult.class)
    @PostMapping(value = "/stat/city/order")
    public AjaxResponseBody<List<DataScreenCityOrderResult>> statCityOrder() {
        List<DataScreenCityOrderResult> result = orderHeadService.statCityOrder();
        return AjaxResponseBody.success(result);
    }

    @ApiOperation(value = "v4.0.1 --> 月销售额", response = DataScreenOrderMonthResult.class)
    @PostMapping(value = "/stat/month/order")
    public AjaxResponseBody<List<DataScreenOrderMonthResult>> statMonthOrder() {
        List<DataScreenOrderMonthResult> statisticalResults = orderHeadService.statMonthOrder("0");
        return AjaxResponseBody.success(statisticalResults);
    }

    @ApiOperation(value = "v4.0.1 --> 全国用户数", response = DataScreenUserResult.class)
    @PostMapping(value = "/stat/user")
    public AjaxResponseBody<DataScreenUserResult> statUser() {
        DataScreenUserResult dataScreenUserResult = userInfoService.statUser();
        return AjaxResponseBody.success(dataScreenUserResult);
    }

    @ApiOperation(value = "v4.0.1 --> 全国酒店星级", response = DataScreenHotelStarResult.class)
    @PostMapping(value = "/stat/star")
    public AjaxResponseBody<List<DataScreenHotelStarResult>> statStar() {
        List<DataScreenHotelStarResult> dataScreenHotelStarResult = hotelInfoService.statStar();
        return AjaxResponseBody.success(dataScreenHotelStarResult);
    }

    @ApiOperation(value = "v4.0.1 --> 全国酒店数量", response = DataGreenHotelTotalResult.class)
    @PostMapping(value = "/stat/hotel/total")
    public AjaxResponseBody<DataGreenHotelTotalResult> statHotel() {
        DataGreenHotelTotalResult dataGreenHotelTotalResult = dataCenterService.statHotelTotal();
        return AjaxResponseBody.success(dataGreenHotelTotalResult);
    }

    @ApiOperation(value = "v4.0.1 --> 优享VIP每月的总酒店数", response = DataGreenVipHotelMonthResult.class)
    @PostMapping(value = "/stat/vip/hotel/month")
    public AjaxResponseBody<List<DataGreenVipHotelMonthResult>> statVipHotelMonth() {
        List<DataGreenVipHotelMonthResult> dataGreenVipHotelMonthResults = dataCenterService.statVipHotelMonth();
        return AjaxResponseBody.success(dataGreenVipHotelMonthResults);
    }
}
